﻿//-----------------------------------------------------------------
//
// @(#)$Id: LackProductRepReport.aspx.cs,v 1.0 2013/12/16 9:50:34 lichunhua Exp $
// @(#)$Author: lichunhua  $
// @(#)$Date: 2013/12/16 9:50:34 $
// @(#)$Description:
//
//
//
//                 All Rights Reserved.
//-----------------------------------------------------------------
using System;
using System.Data;
using ebay.Dal.CenterDB_LTableAdapters;

public partial class UI_Report_LackProductRepReport : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {      
        WebUtility.CheckRight();
        if (!IsPostBack)
        {
            dateFrom.Value = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
            dateTo.Value = DateTime.Now.ToString("yyyy-MM-dd");

            T_LackProductReplaceTableAdapter lackRep = new T_LackProductReplaceTableAdapter();
            Repeater1.DataSource = lackRep.GetData();
            Repeater1.DataBind();
        }
    }
    
    public DataTable DataBing()
    {
        DateTime dfrom = DateTime.Parse(dateFrom.Value);
        DateTime dto = DateTime.Parse(dateTo.Value); 
        T_LackProductReplaceTableAdapter lackRep = new T_LackProductReplaceTableAdapter();
        DataTable dt = lackRep.GetDataByTime(dfrom.ToString("yyyyMMdd"),dto.ToString("yyyyMMdd"));
        return dt;
    }
    //查询
    protected void btnQuery_Click(object sender, EventArgs e)
    {
        DataTable dt = DataBing();
        if (dt != null)
        {
            Repeater1.DataSource = dt;
            Repeater1.DataBind();
        }
    }
    //导出数据表
    protected void btnLackProduct_Click(object sender, EventArgs e)
    {
        if (Session["UserId"] == null)
        {
            WebUtility.ShowMsg("登陆超时,请重新登陆", this);
            return;
        }
        DataTable table = new DataTable();
        table = DataBing();
        if (table != null)
        {
            DataSetToExcel.DataSetOutExcel(table, "缺货替换商品表");
        }
        else
        {
            WebUtility.ShowMsg("无数据", this);
        }
    }
}
